// 加载页对象
const IndexViewController = function () {
    // 公共变量
    const _that = this;
    const _private = {};
    // 初始化，包括整体页面
    _private.init = function () {
        if (_private.isInit === true) {
            return;
        }
        if (_UA) {
            $('.swiper-pc').hide();
        } else {
            $('.swiper-web').hide();
        }
        _private.pcSwiper = new Swiper('.swiper-pc .swiper-container', {
            pagination: '.swiper-pc .pagination',
            loop: true,
            grabCursor: true,
            paginationClickable: true,
            autoplay: 4000,
            autoplayDisableOnInteraction: false
        });
        _private.webSwiper = new Swiper('.swiper-web .swiper-container', {
            pagination: '.swiper-web .pagination',
            loop: true,
            grabCursor: true,
            paginationClickable: true,
            autoplay: 4000,
            autoplayDisableOnInteraction: false
        });
        $('.arrow-left').on('click', function (e) {
            e.preventDefault();
            mySwiper.swipePrev();
        });
        $('.arrow-right').on('click', function (e) {
            e.preventDefault();
            mySwiper.swipeNext();
        });

        $('.nav .nav-list').onePageNav();

        $('.menu-icon').on('click', function () {
            if ($('.menu').hasClass('show')) {
                $('.menu').removeClass('show');
            } else {
                $('.menu').addClass('show');
            }
        });
    };
    // 显示
    _that.show = function () {};

    // 隐藏
    _that.hide = function () {
        _that.onhide && _that.onhide();
        _private.pageEl.hide();
    };

    _private.init();
};

module.exports = IndexViewController;
